package com.listeningframework.boot.autoconfigure.security;

import org.springframework.boot.context.properties.ConfigurationProperties;

/**
 * @author listening
 * @version $Id: ListeningSecurityProperties.java, v 0.1 2015年8月11日 下午11:04:02 listening Exp $
 * Listening Security Properties
 */
@ConfigurationProperties(prefix = "listening.security")
public class ListeningSecurityProperties {
    enum SCHEMA {
        DEFAULT, CUSTOM, PROVIDER
    }

    /**
     * Spring Security Basic Info
     */
    private Basic basic = new Basic();

    /**
     * JWT Security Config
     */
    private Jwt jwt = new Jwt();

    public Jwt getJwt() {
        return jwt;
    }

    public void setJwt(Jwt jwt) {
        this.jwt = jwt;
    }

    public Basic getBasic() {
        return basic;
    }

    public void setBasic(Basic basic) {
        this.basic = basic;
    }

    /**
     * Spring Security Basic
     */
    public static final class Basic {
        /**
         * 是否启用
         */
        private boolean enabled = false;
        /**
         * 是否初始化表结构
         */
        private boolean initSchema = false;
        /**
         * 是否初始化默认用户
         */
        private boolean withDefaultUser = true;
        /**
         * 是否自定义表结构
         */
        private SCHEMA schema = SCHEMA.DEFAULT;
        /**
         * 脚本路径
         */
        private String customSchemaLocation;
        /**
         * 默认Schema名称
         */
        private String customSchemaName;
        /**
         * 默认数据脚本名称
         */
        private String customDataName;

        public boolean isEnabled() {
            return enabled;
        }

        public void setEnabled(boolean enabled) {
            this.enabled = enabled;
        }

        public boolean isInitSchema() {
            return initSchema;
        }

        public void setInitSchema(boolean initSchema) {
            this.initSchema = initSchema;
        }

        public SCHEMA getSchema() {
            return schema;
        }

        public void setSchema(SCHEMA schema) {
            this.schema = schema;
        }

        public boolean isWithDefaultUser() {
            return withDefaultUser;
        }

        public void setWithDefaultUser(boolean withDefaultUser) {
            this.withDefaultUser = withDefaultUser;
        }

		public String getCustomSchemaLocation() {
			return customSchemaLocation;
		}

		public void setCustomSchemaLocation(String customSchemaLocation) {
			this.customSchemaLocation = customSchemaLocation;
		}

		public String getCustomSchemaName() {
			return customSchemaName;
		}

		public void setCustomSchemaName(String customSchemaName) {
			this.customSchemaName = customSchemaName;
		}

		public String getCustomDataName() {
			return customDataName;
		}

		public void setCustomDataName(String customDataName) {
			this.customDataName = customDataName;
		}
        
    }

    /**
     * JWT Configuration Properties
     */
    public static final class Jwt {
        /**
         * 是否启用
         */
        private boolean enabled = false;
        /**
         * JWT加密KEY
         */
        private String secret = "wodliwu";
        /**
         * JWT有效时间30分钟
         */
        private long tokenValidityInSeconds = 60 * 30;
        /**
         * JWT记住登陆有效时长1个月
         */
        private long tokenValidityInSecondsForRememberMe = 30 * 24 * 60 * 60;

        public boolean isEnabled() {
            return enabled;
        }

        public void setEnabled(boolean enabled) {
            this.enabled = enabled;
        }

        public String getSecret() {
            return secret;
        }

        public void setSecret(String secret) {
            this.secret = secret;
        }

        public long getTokenValidityInSeconds() {
            return tokenValidityInSeconds;
        }

        public void setTokenValidityInSeconds(long tokenValidityInSeconds) {
            this.tokenValidityInSeconds = tokenValidityInSeconds;
        }

        public long getTokenValidityInSecondsForRememberMe() {
            return tokenValidityInSecondsForRememberMe;
        }

        public void setTokenValidityInSecondsForRememberMe(long tokenValidityInSecondsForRememberMe) {
            this.tokenValidityInSecondsForRememberMe = tokenValidityInSecondsForRememberMe;
        }
    }

}
